Skip to content

Add missing Field.phone() helper and factory methods for Action/Dashboard/Report#15

Merged
huangyiirene merged 5 commits into
copilot/add-crm-functionality-examplefrom
copilot/fix-action-job-step-error
Jan 19, 2026
Merged

Add missing Field.phone() helper and factory methods for Action/Dashboard/Report#15
huangyiirene merged 5 commits into
copilot/add-crm-functionality-examplefrom
copilot/fix-action-job-step-error

Conversation

Copy link
Copy Markdown
Contributor

Copilot AI commented Jan 19, 2026

Fix CRM Example TypeScript Build Errors ✅

Problem: The CRM example has multiple TypeScript compilation errors preventing CI from passing.

Root Causes:

  1. Field.select() signature mismatch - expects string[] but code passes SelectOption[] objects
  2. Missing phone field type helper in Field factory
  3. Action, Dashboard, and Report are only types, not runtime objects with .create() methods

Solution:

  • Add phone field type helper to Field factory
  • Update Field.select()/Field.multiselect() to support both old and new API signatures (backward compatible)
  • Add factory methods (Action.create, Dashboard.create, Report.create) using z.input for proper default handling
  • Add comprehensive test coverage (12 new tests)
  • Add JSDoc comments documenting the API
  • Fix spread order in select/multiselect to avoid option duplication
  • Security scan: ✅ No vulnerabilities
  • Code review: ✅ Addressed feedback

Backward Compatibility:

// Old API (still works)
Field.select(['High', 'Low'], { label: 'Priority' })

// New API (now supported)
Field.select({ 
  options: [{label: 'High Priority', value: 'high', color: '#FF0000'}], 
  label: 'Priority' 
})

Test Results: ✅ All 279 tests passing
Build Status: ✅ All packages build successfully (CRM, TODO, docs)
Security: ✅ No vulnerabilities detected

Original prompt

引用: https://github.com/objectstack-ai/spec/actions/runs/21135959933/job/60779299734#step:8:1


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

@vercel
Copy link
Copy Markdown

vercel Bot commented Jan 19, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Review Updated (UTC)
spec Ready Ready Preview, Comment Jan 19, 2026 0:12am

Request Review

- Add phone field type helper to Field factory
- Update Field.select/multiselect to support both array and object signatures
- Add factory methods (Action.create, Dashboard.create, Report.create)
- Use z.input and parse for factory methods to support default values

Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes TypeScript compilation errors in the CRM example by enhancing the Field factory API and adding factory helper methods for UI components. The changes enable both legacy string-array syntax and new object-based configuration for select fields, while adding missing field type helpers and runtime factory methods.

Changes:

  • Added phone field type helper and dual-signature support for select/multiselect fields (backward compatible)
  • Added factory helper methods (Action.create, Dashboard.create, Report.create) with proper type inference using z.input
  • Restructured documentation metadata hierarchy by moving root: true from parent to child sections

Reviewed changes

Copilot reviewed 9 out of 9 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
packages/spec/src/data/field.zod.ts Added phone helper and refactored select/multiselect to accept both string arrays and SelectOption objects
packages/spec/src/ui/action.zod.ts Added Action.create() factory method with additional exported types
packages/spec/src/ui/dashboard.zod.ts Added Dashboard.create() factory method with exported widget type
packages/spec/src/ui/report.zod.ts Added Report.create() factory method with additional exported types
content/docs/references/meta.json Removed root: true from parent metadata
content/docs/references/data/meta.json Added root: true to Data Protocol section
content/docs/references/ui/meta.json Added root: true to UI Protocol section
content/docs/references/system/meta.json Added root: true to System Protocol section
content/docs/references/ai/meta.json Added root: true to AI Protocol section

Comment thread packages/spec/src/data/field.zod.ts Outdated
finalConfig = optionsOrConfig;
}

return { type: 'select', ...finalConfig, options } as const;
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The spread order ...finalConfig, options means that if finalConfig contains an options property, it will be overwritten by the options variable. Consider using options, ...finalConfig to ensure the parsed options take precedence, or explicitly handle the options property separately to avoid confusion.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 49030d1. Now extracting options from config object and placing processed options first in spread order to ensure they always take precedence.

Comment thread packages/spec/src/data/field.zod.ts Outdated
finalConfig = optionsOrConfig;
}

return { type: 'multiselect', ...finalConfig, options } as const;
Copy link

Copilot AI Jan 19, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The spread order ...finalConfig, options means that if finalConfig contains an options property, it will be overwritten by the options variable. Consider using options, ...finalConfig to ensure the parsed options take precedence, or explicitly handle the options property separately to avoid confusion.

Copilot uses AI. Check for mistakes.
Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed in 49030d1. Now extracting options from config object and placing processed options first in spread order to ensure they always take precedence.

@huangyiirene
Copy link
Copy Markdown
Collaborator

@copilot fix

- Add tests for Field.phone() helper
- Add tests for Field.select() backward compatibility (old and new API)
- Add tests for Field.multiselect() backward compatibility
- Add tests for Action.create() with default value handling
- Add tests for Dashboard.create() with default value handling
- All 279 tests passing

Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
Document backward-compatible API with examples for both old and new signatures

Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix action job step error Add missing Field.phone() helper and factory methods for Action/Dashboard/Report Jan 19, 2026
Copilot AI requested a review from huangyiirene January 19, 2026 12:08
- Extract options from config object to avoid confusion
- Change spread order to options first, then finalConfig
- Ensures processed options always take precedence

Co-authored-by: huangyiirene <7665279+huangyiirene@users.noreply.github.com>
Copy link
Copy Markdown
Contributor Author

Copilot AI commented Jan 19, 2026

@copilot fix

Fixed the spread order issue in select/multiselect field helpers (commit 49030d1). The options property is now extracted from the config object and the processed options array always takes precedence.

@huangyiirene huangyiirene marked this pull request as ready for review January 19, 2026 12:16
@huangyiirene huangyiirene merged commit 8beab63 into copilot/add-crm-functionality-example Jan 19, 2026
2 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants